<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>使两字符串互为字母异位词的最少步骤数</title>
</head>
<body>
  <script>
    function fn(s, t) {
      let sArr = new Array(26).fill(0);
      let tArr = new Array(26).fill(0);
      for (let ch of s) {
        // 97 是'a'.charCodeAt()的编码
        sArr[ch.charCodeAt() - 97]++
      }
      for (let ch of t) {
        tArr[ch.charCodeAt() - 97]++
      }
      let ans = 0;
      for (let i = 0; i < 26; i++) {
        ans += Math.abs(sArr[i] - tArr[i])
      }
      return ans;
    }
    console.log(fn('leetcode', 'coats'))
  </script>
</body>
</html>